#!/usr/bin/python
# -*- coding: UTF-8 -*-

from mathlib import *
import time
start = time.clock()

triangle = 0 # the "k"nd triangle number
k = 1 
d = 1        # d means divisor

nb_div = 0   # our control quantity

max = 0
objective = 500

while ( nb_div < objective ):
  triangle += k
  d = 2
  nb_div = 2 # 2, because any number is divisible by itself and by 1
  #~ if ( ( triangle % 1000 ) % 2 == 0 or max > objective*10000/(objective+1)*10  or triangle == 1 ):
  if ( triangle % 100 == 0 or max >= objective*9/10 or triangle == 1 ):
    while ( d <= triangle/2 ):
      if ( triangle % d == 0 ):
        nb_div += 1
      d += 1
    if  ( max < nb_div ):
      max = nb_div
      print triangle, nb_div
  k += 1



print "problem solved in ", (time.clock() - start), "s"
